// See LICENSE.TXT for terms of use, and copyright information

#define OP_JMP		0xc0
#define OP_SR		0xb0
#define OP_RRCOPY0	0xa0
#define OP_ICRGBI	0x90
#define OP_RSVD1	0x80

#define OP_IDLY		0x7f
#define OP_DLY16	0x7e
#define OP_DLY		0x7d
#define OP_DLY8		0x7c
#define OP_RED		0x7b
#define OP_GREEN	0x7a
#define OP_BLUE		0x79
#define OP_BRIGHT	0x78

#define OP_RGBI		0x77
#define OP_RGB		0x76
#define OP_IRED		0x75
#define OP_IGREEN	0x74
#define OP_IBLUE	0x73
#define OP_IBRIGHT	0x72
#define OP_CRGB		0x71
#define OP_CRGBI	0x70

#define OP_CMPRR	0x69
#define OP_BEQ		0x65
#define OP_BNE		0x63
#define OP_RND		0x5f

#define OP_RRCOPY	0x59
#define OP_RRSWAP	0x58
#define OP_IRGBI	0x57
#define OP_IRGB		0x56
#define OP_STEPTO	0x55

#define OP_DEEPSLEEP	0x02
#define OP_NOP		0x01
#define OP_EOP		0x00

// status flags meant to losely resemble those on a 6502
#define ST_C 0
#define ST_E 1
#define ST_M 2
#define ST_P 3
#define ST_V 4

// internal status flag
#define IST_EXIT 0
#define IST_DEEPSLEEP 1
#define IST_IDLE 2
#define IST_ERROR 3
#define IST_PAUSED 7

// some common defines in case we ever change these values:
#define VM_MAX_PROGSIZE		40
#define VM_NUM_REGISTERS	16
#define VM_MAX_EESTORAGE	128

//extern uint8_t pc, st, ist;               // program count, accumulator value, and status register
//extern uint8_t program[VM_MAX_PROGSIZE];
extern uint8_t ist;               // program count, accumulator value, and status register
extern uint8_t reg[VM_NUM_REGISTERS];

void wipe_program(void);
void load_program(uint8_t progno);
void step_program(void);
void run_program(void);
